package com.nbsaas.boot.project.data.entity;


import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.jpa.data.entity.User;
import com.nbsaas.boot.rest.filter.Operator;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "收款管理", model = "收款单", searchWidth = "100", viewWidth = "120")
@Entity
@Table(name = "nb_receipt")
public class Receipt extends AbstractEntity {


    @SearchItem(label = "项目名称", name = "project", key = "project.id", type = InputType.select, classType = Long.class, operator = Operator.eq)
    @FormField(title = "项目名称", grid = true, type = InputType.select, option = "project", required = true, width = "200")
    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private Project project;


    @FieldConvert
    @FieldName
    @FormField(title = "收款人", grid = true, col = 12, ignore = true)
    @ManyToOne(fetch = FetchType.LAZY)
    private User creator;

    @FormField(title = "开始日期", type = InputType.date, sortNum = "4", width = "160", grid = true, required = true, sort = true)
    private Date beginDate;

    @FormField(title = "收款金额", grid = true, col = 12, sort = true, required = true)
    private BigDecimal money;


    @FormField(title = "收款附件", sortNum = "10", type = InputType.image, col = 24)
    private String file;

    @FormField(title = "备注", sortNum = "10", type = InputType.textarea, col = 24)
    private String note;
}
